/*绑定回车到查询按钮*/
$(function () {
	$(document).keydown(function () { 
		if(event.keyCode == 13) { 
		$("#btnTuiFeicx").trigger('click'); 
		return false;
		}
	});
});

//查询变量设置
var kaishisj =  '';
var jieshusj = 	'';
var xingmingsj ='';

//增加当前页码，收费ID。定位行ID，定位判断四个变量
var pageNumber=1;
var tfdingweiid='';
var dingwei='';
var dwpanduan=true;
var dwkaishisj='';
var dwjieshusj='';
var dwxingmingsj='';
var huanzheid='';
//获取详情退费ID传值Fjh
function getTfdingwei(pretfid,prepageNo,prekaishisj,prejieshusj,prexingmingsj){
	dwkaishisj=prekaishisj;
	dwjieshusj=prejieshusj;
	dwxingmingsj=prexingmingsj;
	tfdingweiid=pretfid;
	if(prepageNo!=null&&prepageNo!=''&&prepageNo!='null'){
		pageNumber=prepageNo;
	}
}
//跳转进退费记录详情
function toTuiFeixq(id,prepageNo,preXingMingsj,preKaishisj,preJieshusj){
	var rexingmingsj=encodeURI(encodeURI(xingmingsj));
	 $('.cxtj-neirk').load(path+ "/views/chaxun-tongji/chaxtj-tfjl-tfxq.jsp?yemianrk=tuifeijl&ID="+id+"&pageNo="+prepageNo+"&dwxingmingsj="+rexingmingsj+"&dwkaishisj="+kaishisj+"&dwjieshusj="+jieshusj);
}

//退费记录查询按钮
$("#btnTuiFeicx").click(function () {
        xingmingsj =$(".tuifjl .list-name input").val();
	    kaishisj = $('#tfjl-kaishjsj').val();
	    jieshusj = $('#tfjl-jieshusj').val();
	    dwpanduan=false;
	    pageNumber=1;
	    getTuifeifeijl();
    });
//获取初始时间
function getShijian(prekaishisj,prejieshusj){
	//退费记录查询清空按钮
$("#btnTuiFeiReset").click(function () {
        $(".tuifjl .list-name input").val("");
        $('#tfjl-kaishjsj').val(prekaishisj);
    	$('#tfjl-jieshusj').val(prejieshusj);
//    	条件重置后进行查询
    	if(prekaishisj!=null){
		kaishisj=prekaishisj;
		jieshusj=prejieshusj;
		xingmingsj='';
		dwpanduan=false;
	    pageNumber=1;
		getTuifeifeijl();
	}
    });
	if(prekaishisj!=null||dwkaishisj!='null'){
		if(dwkaishisj!=''&&dwkaishisj!='null'){
			kaishisj=dwkaishisj;
			jieshusj=dwjieshusj;
			$('#tfjl-kaishjsj').val(kaishisj);
			$('#tfjl-jieshusj').val(jieshusj);
		}else{
			kaishisj=prekaishisj;
			jieshusj=prejieshusj;
		}
		if(dwxingmingsj!=''&&dwxingmingsj!='null'){
			xingmingsj=dwxingmingsj;
			$("#chaxtj-qfjl-xingmingsj").val(dwxingmingsj);
		}else {
			xingmingsj='';
		}
		getTuifeifeijl();
	}
}

/** 
 * @Title: getTuifeifeijl 
 * @Description:  退费记录列表查询
 */
function getTuifeifeijl(){
	    var totalNumber = 0;
		var params={
			kaishisj:kaishisj,
			jieshusj:jieshusj,
			xingmingsj:xingmingsj
		};
		$.ajax({
		    type: "get",
		    //获取json文件路径
		    url: "../chaxuntjtfjl/getCount",
		    //传送数据
		    data: params,
		    async: false,
		    //请求成功完成后要执行的方法
		    success: function (data) {
		    	totalNumber = data;
		    	if(totalNumber == 0){
					$("#chaxtjtfjl-tbneirong").css("display", "none");
					$("#tf-img").html("<img src='" + path + "/image/chaxtj/cxtj-nobody.png'>");
				} else {
					$("#chaxtjtfjl-tbneirong").css("display", "block");
					$("#tf-img").html("");
				}
		    }
		});
		function getTuiFei(name) {
			$('#tbtuifeijl').html('');
  			  var container = $('#pagination-' + name);
  			  container.pagination({
  			    dataSource:'../chaxuntjtfjl/getBypage?kaishisj='+encodeURI(kaishisj)+'&jieshusj='+encodeURI(jieshusj)+'&xingmingsj='+xingmingsj,
  			    locator: 'entities',
  			    pageSize: 12,
  			    totalNumber: totalNumber,
  			    pageNumber:pageNumber,
  			     //增加总记录数
				showNavigator: true,
		   	    formatNavigator: '共 <%= totalNumber %> 条',
  			    callback: function(data, pagination) {
  		    			var content = '';
//  		    			var xingmingsj = $('#chaxtj-qfjl-xingmingsj').val();
//  		    			var kaishisj = $('#tfjl-kaishjsj').val();
//  		    			var jieshusj = $('#tfjl-jieshusj').val();
  		    			$(data).each(function(index, value) {
  		    				if(this.nianling==null){
    		    					var nianling="";
    		    			}else if(this.nainlingdw==null){
    		    					var nianling=this.nianling;
    		    				}else{
    		    					var nianling=this.nianling+this.nainlingdw;
    		    					}
  		    				if(this.xingbie==1){
  		    					var sex="男";
  		    				}else if(this.xingbie==2){
  		    					var sex ="女";
  		    				}else{
  		    					var sex ="";
  		    				}
  		    				var zhenduan=this.jibingmc  || '';
  		    				var index=((pagination.pageNumber-1)*pagination.pageSize)+index+1;
  		    				content += '<tr class="user" id="tfhang'+index+'">'+
  		    				'<td width="6%">'+index+'</td>'+
  		    				'<td width="10%" class="left"><span class="icon-user" onclick=getHuanzhe('+this.huanzheid+')></span>'+this.xingming+'</td>'+
  		    				'<td width="6%">'+sex+'</td>'+
  		    				'<td width="6%">'+nianling+'</td>'+
  		    				'<td width="12%">'+this.tuifeirq+'</td>'+
  		    				'<td class="left" width="30%">'+zhenduan+'</td>'+
  		    				'<td width="10%" class="right">'+parseFloat(this.tuifeije).toFixed(2)+'</td>'+
  		    				'<td width="10%">'+this.tuifeir+'</td>'+
  		    				'<td width="10%">'+
  		    				'<div class="table-operation">'+
  		    				'<span class="obtn3" id="'+this.id+'"onclick="toTuiFeixq('+this.id+','+pagination.pageNumber+',\''+xingmingsj+'\','+kaishisj+','+jieshusj+')">详情</span>'+
  		    				'</div></td></tr>';
  		    				//index定位
  		    				if(tfdingweiid==this.id){
  		    					dingwei=index;
  		    				}
  		    			});
  		    			$('#tbtuifeijl').html(content);
  		    			//查询状态定位Fjh
				        if(dingwei!=null&&dingwei!=''){
				 	        $('#tbtuifeijl').find('tr[id="tfhang'+dingwei+'"]').addClass('list-tr');
				        }
						//点击查询按钮和重置按钮定位状态消失
				        if(!dwpanduan){
				        	$('#tbtuifeijl').find('tr[id="tfhang'+dingwei+'"]').removeClass('list-tr');
				        }
  			    }
  			  });
		  return container;
		}
		getTuiFei('fenytfjl');
		if(totalNumber <= 12) {
			$('#pagination-fenytfjl').css('display', 'none');
		}else{
			$('#pagination-fenytfjl').css('display', 'block');
		}
}


